﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Eje5_page1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
        if (!IsPostBack)
        {
            ListItemCollection ciudades = new ListItemCollection();
            ddlMem.Items.Add(new ListItem("2gb", "200"));
            ddlMem.Items.Add(new ListItem("4gb", "375"));
            ddlMem.Items.Add(new ListItem("6gb", "500"));
            chkAcc.Items.Add(new ListItem("Monitor LCD", "2000,50"));
            chkAcc.Items.Add(new ListItem("HD 500GB", "550,50"));
            chkAcc.Items.Add(new ListItem("Grabador DVD", "1200"));
        }
    }

    protected void btnCalc_Click(object sender, EventArgs e)
    {
        float total = 0;
        total = float.Parse(ddlMem.SelectedItem.Value);
        for (int i = 0; i < chkAcc.Items.Count; i++)
        {
            if (chkAcc.Items[i].Selected)
            {
                total += float.Parse(chkAcc.Items[i].Value);
            }
        }
        lblPrice.Text = "El precio final es de: $" + total.ToString();
    }
}